package Basic.day03;

import java.math.BigDecimal;

public class IfElseDemo {
    public static void main(String[] args) {
//        for (int i = 0; i < 5; i++) {
//            //计算最终价格
//            Scanner sc = new Scanner(System.in);
//            BigDecimal money = sc.nextBigDecimal();
//            finalMoney(money);
//            BigDecimal bigDecimal = new BigDecimal(0.9);
//        }
        BigDecimal bigDecimal1 = new BigDecimal(0.9);
        BigDecimal divide = bigDecimal1.divide(new BigDecimal(2), 3, BigDecimal.ROUND_DOWN);
        System.out.println("divide = " + divide);

        BigDecimal scale = new BigDecimal(1.2).setScale(0, BigDecimal.ROUND_UP);
        BigDecimal scale1 = new BigDecimal(-1.2).setScale(0, BigDecimal.ROUND_UP);
        System.out.println("scale = " + scale);
        System.out.println("scale1 = " + scale1);

        BigDecimal scale3 = new BigDecimal(-1.2568).setScale(2, BigDecimal.ROUND_DOWN);
        BigDecimal scale4 = new BigDecimal(1.2568).setScale(2, BigDecimal.ROUND_DOWN);
        System.out.println("scale3 = " + scale3);
        System.out.println("scale4 = " + scale4);

        BigDecimal scale5 = new BigDecimal(-1.2568).setScale(2, BigDecimal.ROUND_CEILING);
        BigDecimal scale6 = new BigDecimal(1.2568).setScale(2, BigDecimal.ROUND_CEILING);
        BigDecimal scale7 = new BigDecimal(1.2528).setScale(2, BigDecimal.ROUND_CEILING);
        System.out.println("scale5 = " + scale5);
        System.out.println("scale6 = " + scale6);
        System.out.println("scale7 = " + scale7);

        BigDecimal scale8 = new BigDecimal("5.5").setScale(0, BigDecimal.ROUND_HALF_UP);// 6
        BigDecimal scale9 =new BigDecimal("1.6").setScale(0, BigDecimal.ROUND_HALF_UP); // 2
        BigDecimal scale10 =new BigDecimal("1.0").setScale(0, BigDecimal.ROUND_HALF_UP); // 1
        BigDecimal scale11 =new BigDecimal("-1.0").setScale(0, BigDecimal.ROUND_HALF_UP); // -1
        BigDecimal scale12 =new BigDecimal("-1.6").setScale(0, BigDecimal.ROUND_HALF_UP); // -2
        BigDecimal scale13 =new BigDecimal("-5.5").setScale(0, BigDecimal.ROUND_HALF_UP); // -6
        System.out.println("scale8 = " + scale8);
        System.out.println("scale9 = " + scale9);
        System.out.println("scale10 = " + scale10);
        System.out.println("scale11 = " + scale11);
        System.out.println("scale12 = " + scale12);
        System.out.println("scale13 = " + scale13);

    }

    private static void finalMoney(BigDecimal money) {
        if (money.compareTo(new BigDecimal(500)) >= 0) {
            System.out.println("打八折：" + money.multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_UP));
        } else {
            System.out.println("打九折：" + money.multiply(new BigDecimal(0.9)).setScale(2, BigDecimal.ROUND_UP));
        }
    }
}
